package com.jinyou.chengfengshop.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jinyou.chengfengshop.R;
import com.jinyou.chengfengshop.activity.AddOrderPhotoActivity;
import com.jinyou.chengfengshop.bean.infosBean;

import java.util.List;

/**
 * Created by zhuzhiqiang on 2018/9/23.
 */

public class AddOrderPhotoAdapter extends RecyclerView.Adapter<AddOrderPhotoAdapter.ViewHolder> {
    private List<infosBean> ifb;
    private Context context;

    public AddOrderPhotoAdapter(Context applicationContext, List<infosBean> ifb) {
        this.context = applicationContext;
        this.ifb = ifb;
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_order_addphoto, parent, false);
        AddOrderPhotoAdapter.ViewHolder vh = new AddOrderPhotoAdapter.ViewHolder(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder,final int position) {
        holder.rdName_tv.setText(ifb.get(position).getRouteAddr());
        holder.price_tv.setText("¥"+ifb.get(position).getPsMoney());
        holder.order_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AddOrderPhotoActivity.instanece.openCamera(ifb.get(position).getId(),ifb.get(position).getStationId());
            }
        });
    }

    @Override
    public int getItemCount() {
        return ifb.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        private TextView rdName_tv;
        private TextView price_tv;
        private ImageView order_img;
        public ViewHolder(View itemView) {
            super(itemView);
            rdName_tv = (TextView) itemView.findViewById(R.id.rdName_tv);
            price_tv = (TextView) itemView.findViewById(R.id.price_tv);
            order_img = (ImageView) itemView.findViewById(R.id.order_img);
        }
    }
}
